<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8" />
    <meta name="renderer" content="webkit" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>验证邮箱 - 空明物联网服务平台</title>
    <link rel="stylesheet" href="/static/css/bootstrap.min.css" />
    <link rel="stylesheet" href="/static/css/main.css?version=1.0.0" />
</head>

<body>
    <div class="wrapper" id="page_index">
        <h1><span class="title">空明物联网服务平台</span></h1>
        <div class="sidebar">
            <ul id="menu" class="menu">
                <li><a href="login.html">登录</a></li>
                <li><a href="reg.html">注册</a></li>
            </ul>
        </div>
    </div>
    <div class="main-content">
        <div class="container-fluid">
            <br />
            <h2>验证邮箱</h2>
            <hr>
            <span>正在为您激活邮箱验证，请稍后... 如果失败可点击重试</span>

            <br/>
            <br/>
            <br/>
            <br/>
            <button id="btn-verify-email" class="btn btn-primary btn-sm" type="submit">
                重试
            </button>

            
            <div class="footer">
                <span>© 2020 空明物联网 <a href="http://www.beian.miit.gov.cn/" target="_blank">鄂ICP备15000810号-1</a></span>
            </div>
        </div>

    </div>
    <script src="/static/js/jquery-2.1.4.min.js"></script>
    <script src="/static/js/gt.js"></script>
    <script src="/static/js/base.js?version=1.0.0"></script>
    <script>
        var code;

        // 发送验证请求
        function send_verify_email() {
            $.ajax({
                url: getServiceURL("verifyemail"),
                data: {
                    "code": code,
                },
                type: "get",
                async: true,
                success: function (res) {
                    if (res.code == 0) {
                        alert("您的邮箱已经激活成功, 点击确定后带您回到首页")
                        setTimeout(function () {
                            location.href = "./";
                        }, 500);
                    } else {
                        return alert(res.msg);
                    }
                }
            });
        }


        $(document).ready(function () {
            code = getUrlParam("code");
            if (code == null) {
                return alert("缺少参数");
            }

            send_verify_email();

        });

        $("#btn-verify-email").click(function () {
            send_verify_email();
        });
    </script>
</body>

</html>